<?php
/**
 * The main template file.
 *
 * This is  template file in a crazyminecraft.com
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://crazyminecraft.com
 *
 * @package WordPress
 * @subpackage crazyminecraft.com
 * @since crazyminecraft.com 1.0
 */
?>
<?php get_header();?>
<?php
if (isset($_REQUEST['s'])) : ?>
	<?php get_template_part( 'loop', 'post' );?>
<?php else : ?>
<?php
$args = array(1,4,7,2,3,5,6);

foreach($args as $cat_id) :
        $cat_item = get_category($cat_id,false);
	$cat_id = $cat_item->term_id;
?>
<div id="category-<?php echo $cat_id;?>" class="category-home">
	<h1 class="category-title">
		<a href="<?php echo get_category_link( $cat_item->term_id )?>" title="View all post in <?php echo $cat_item->name;?>"><?php echo $cat_item->name;?></a>
	<?php if($cat_id == 1){ ?>
	<span><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 468x15 crazyminecraft.net [Ngang] -->
<ins class="adsbygoogle"
     style="display:inline-block;width:468px;height:15px"
     data-ad-client="ca-pub-8183633048366349"
     data-ad-slot="1754374462"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></span>
	<?php }?>
	<?php if($cat_id == 4){ ?>
	<span><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 468x15 crazyminecraft.net [Ngang 2] -->
<ins class="adsbygoogle"
     style="display:inline-block;width:468px;height:15px"
     data-ad-client="ca-pub-8183633048366349"
     data-ad-slot="5626170867"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></span>
	<?php }?>
	</h1>
<?php

$per_page=2;
if ( $cat_id == 1 || $cat_id == 4 || $cat_id == 7 )
{
	$per_page = 3;
}
//query_posts("cat=$cat_id&posts_per_page=$per_page");
query_posts("cat=$cat_id&posts_per_page=$per_page&orderby=modified");
if ( have_posts() ) :
	$iIndex = 0;
	while ( have_posts() ) : the_post();
?>
	<div class="<?php if ($iIndex%2 == 0) echo 'post-odd'; else echo 'post-even'?> post-<?php the_ID();?> post type-post status-publish format-standard hentry category-uncategorized" id="post-<?php the_ID();?>">
		<div>
			<div id="thumbnail-<?php the_ID();?>" class="thumbnail"><?php the_post_thumbnail(); ?></div>
			<div id="post-descript-<?php the_ID();?>" class="post-descript">
				<h2 class="entry-title">
					<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
				</h2>
				<div class="postAuthor">by <?php the_author_posts_link(); ?> on <?php the_time('l, F jS, Y') ?> | <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> | <strong><?php echo getPostViews(get_the_ID());?></strong></div>
				<div class="entry">
					<?php
						$content = get_the_content();
						$trimmed_content = wp_trim_words( $content, 20, '<p><a href="'. get_permalink() .'"> Continue to reading →</a></p>' );
						echo $trimmed_content;
					?>
				</div>
			</div>
			<div style="clear: both;"></div>
		</div>
		</div>
 
<?php
	$iIndex ++;
	endwhile;
endif;
?>
	</div>
<?php
endforeach;
endif;
?>
</div><!-- /im-mainContent -->
<?php get_sidebar('right');?>
<?php get_footer();?>